import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter as Router, Route, Switch,Redirect } from "react-router-dom";
import zhCN from 'antd/lib/locale/zh_CN';
import {ConfigProvider} from 'antd'

import "@/assects/css/reset.css";

import {mainRouter} from "@/router";

import store from './store';
import {Provider} from 'react-redux';

import App from './App';
ReactDOM.render(
    <Provider store={store}>
        <ConfigProvider locale={zhCN}>
        <Router>
            <Switch>
                {/* <Route path="/admin" render={(routerProps) => {
                    //此处需要进行权限的验证才能进行访问
                    return store.getState().user.isLogin ? <App {...routerProps}/> : <Redirect to="/login"/>
                }}/> */}
                <Route path="/admin"  component={App}/>
                {
                    mainRouter.map(route => {
                        return <Route key={route.pathname}  path={route.pathname} component={route.component}></Route>
                    })
                }
                {/*访问/页面，进入admin页面*/}
                <Redirect to="/admin" from="/" exact/>
                {/*访问其他不存在页面，跳转到404*/}
                <Redirect to="/404" />
            </Switch>
        </Router>
    </ConfigProvider>
    </Provider>,

    document.getElementById('root')
);
